// https://www.acwing.com/activity/content/problem/content/823/
#include <iostream>
#include <vector>
using namespace std;

int lower_bound(vector<int>& nums, int key) {
    int left = 0;
    int right = nums.size() - 1;
    int result = nums.size();
    while (left <= right) {
        int mid = left + (right - left) / 2;
        if (nums[mid] == key) {
            result = min(result, mid);
            right = mid - 1;
        }
        else if (nums[mid] < key) {
            left = mid + 1;
        }
        else {
            right = mid - 1;
        }
    }
    return result ==  nums.size() ? -1:result;
}

int upper_bound(vector<int>& nums, int key) {
    int left = 0;
    int right = nums.size() - 1;
    int result = -1;
    while (left <= right) {
        int mid = left + (right - left) / 2;
        if (nums[mid] == key) {
            result = max(result, mid);
            left = mid + 1;
        }
        else if (nums[mid] < key) {
            left = mid + 1;
        }
        else {
            right = mid - 1;
        }
    }

    return result;
}

void search(vector<int>& nums, int key) {
    int r1 = lower_bound(nums, key);
    if (r1 == -1) {
        cout<<"-1 -1"<<endl;
    } else {
        cout<<r1<<" ";
        int r2 = upper_bound(nums, key);
        cout<<r2<<endl;
    }

}

int main() {
    int n, k;
    cin>>n>>k;
    vector<int> nums(n);
    for (int i=0; i<n; i++) {
        cin>>nums[i];
    }

    int key;
    for (int i=0; i<k; i++) {
        cin>>key;
        search(nums, key);
    }
    return 0;
}